<%@ page language="java" import="java.util.*,com.beans.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title></title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	
	<script type="text/javascript" src="js/jquery-1.8.0.js"></script> 
	<script type="text/javascript">
		$(function(){
			$("#ch_checkall,#top_ch_checkall").click(function(){
				if(this.checked){
					$("input[name=ck_id]").attr("checked","checked");
				}else{
					$("input[name=ck_id]").removeAttr("checked");
				}		
			});
					
			$("table tr").mouseover(function(){
				$(this).css("background","#D3EAEF");
				$(this).siblings().css("background","white");
			});
		});
		
		//删除角色
		function del(id){
			if(confirm('确定要删除吗')){
				var currentAdminId=${session_admin.id};  //取到Session中的 admin 的 id
				if(currentAdminId==''){
					alert("当前用户的session已失效!请重新登录");
					window.top.location.href = "${pageContext.request.contextPath}/login.jsp";
				}
				else{
					if(currentAdminId==id){
						alert("不能删除自已!");
					}
					else{
						window.location.href="${pageContext.request.contextPath}/RoleServlet.do?flag=del&id="+id;
					}
				}
			}
		}
		
	</script>

	<link rel="stylesheet" type="text/css" href="css/maintable.css" ></link>
	
	<style type="text/css">
		.desc{
			width:200px;
            word-break:break-all;
            display:-webkit-box;
            -webkit-line-clamp:1;
            -webkit-box-orient:vertical;
            overflow:hidden;
		}
	</style>

  </head>
  
  <body>
	 <div class ="div_title">
		<div class="div_titlename"> <img src="images/san_jiao.gif" ><span>系统中的角色列表</span></div>
	 </div>
	 
	 <table class="main_table">
	     <tr>
 			    <th>角色名称</th> 		
 			    <th>角色描述</th>  
 			    <th>操作</th>
 		</tr>
 		
 		<c:forEach var="role" items="${roleList }">
 			<tr>
 				<td>${role.roleName }</td>	
 				<td> 
 					<div class="desc">
 						<a title="${role.des }">${role.des }</a> 
 					</div>
 				</td>	
 				<td>
 					<a href="RoleServlet.do?flag=searchforupdate&id=${role.id}">修改</a> |  
	 			    <a href="RoleServlet.do?flag=delete&id=${role.id}" onclick="return confirm('确定要删除吗')">删除</a>  | 
 					<a href="RoleServlet.do?flag=roleEdit&roleId=${role.id }">角色权限分配</a> 
 				</td>
 			</tr>
 		</c:forEach>
	</table>
  </body>
</html>

